<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SimpleTimer, ver. 1.0.0</title>

<style type='text/css'>
/*  body         { font-family: MS Sans Serif; font-size: 12pt; } */
  h1           { font: bold 14pt Arial; margin-bottom: 10px; }
  h2           { font: bold 12pt Arial; margin-bottom: 10px; margin-top: 40px; }
  td.name      { background-color: #00FFCC; width: 120px; font-weight: bold; }
  td.desc      { background-color: #F0F0F0; }
  td.default   { background-color: #F0F0F0; }
  ul           { margin-left: 15px; margin-top: 5px; }
  li           { margin-bottom: 10px; }
  .declaration { font-weight: bold; }
</style>

</head>


<body topmargin='15' bottommargin='15' leftmargin='10' rightmargin='10'>

<a name='Top'><h1>SimpleTimer, ver. 1.0.0</h1>


<a href='#Properties'>[Properties]</a> <a href='#Methods'>[Methods]</a> <a href='#Events'>[Events]</a>
<br>
<a href='#Howto'>[How To Use]</a> <a href='#Bugs'>[Known Bugs]</a> <a href='#Comments'>[Comments]</a>
<br>


<p>
SimpleTimer is a timer class. It is more lightweight than a TTimer component, as it doesn't
require a handle, and since it's derived from TObject there's less overhead. This makes
it ideal for developers who need a timer in their own components or applications, but want
to keep the resource usage minimal.
</p>


<a name='Properties'></a><h2>Properties</h2>

<table cellpadding='2' cellspacing='2' border='0' width='100%'>
<tr>
  <td class='name' valign='top'>Owner</td>
  <td class='desc' valign='top'><span class='declaration'>property Owner: TComponent;</span><br>
  The owner of the timer.</td>
  <td class='default' valign='top' nowrap>Read-only</td>
</tr>
<tr>
  <td class='name' valign='top'>Active</td>
  <td class='desc' valign='top'><span class='declaration'>property Active: Boolean;</span><br>
  Whether the timer is running.</td>
  <td class='default' valign='top' nowrap>Read-only</td>
</tr>
</table>



<a name='Methods'></a><h2>Methods</h2>

<table cellpadding='2' cellspacing='2' border='0' width='100%'>
<tr>
  <td class='name' valign='top'>Create</td>
  <td class='desc' valign='top'><span class='declaration'>type TSimpleTimerCallBackProc = procedure(AOwner: TComponent); stdcall;<br>
  constructor (AOwner: TComponent; CallBackProc: TSimpleTimerCallBackProc);</span><br>
  Creates a new TSimpleTimer instance. You need to declare a procedure of type 
  TSimpleTimerCallBackProc which will be called continuously at the interval you specify 
  in the Start method.<br>
  <b>NOTE:</b> Be sure to declare the <i>stdcall</i> directive, as is normal practice
  with callback methods.<br>
  <b>NOTE:</b> The callback method cannot be part of any class. It must be a simple method.</td>
  <td class='default' valign='top'>Returns new TSimpleTimer object</td>
</tr>
<tr>
  <td class='name' valign='top'>Start</td>
  <td class='desc' valign='top'><span class='declaration'>function Start(MilliSecs: Cardinal): Boolean;</span><br>
  Starts the timer, using the specified interval in millisecs. If the timer is already running
  it will be stopped, then restarted with the new interval.<br>
  <b>NOTE:</b> If the method returns false it means the system has run out of timer resources.
  That's bad.</td>
  <td class='default' valign='top'>Returns true or false</td>
</tr>
<tr>
  <td class='name' valign='top'>Stop</td>
  <td class='desc' valign='top'><span class='declaration'>function Stop: Boolean;</span><br>
  Stops the timer.</td>
  <td class='default' valign='top'>Returns true or false</td>
</tr>
</table>



<a name='Events'></a><h2>Events</h2>

<ul>
<li>No events. In stead your callback method is called when the timer fires.
</li>
</ul>



<a name='Howto'></a><h2>How To Use</h2>

<ul>
<li><b>Creating and starting a SimpleTimer object</b><br>
This example creates a SimpleTimer object associated with a TForm, using TimerProc1 
as a callback method, then starts the timer so it fires every second:
<pre>procedure TForm1.FormCreate(Sender: TObject);
begin
  SimpleTimer1 := TSimpleTimer.Create(Self, @TimerProc1);
  SimpleTimer1.Start(1000);
end;</pre>
</li>

<li><b>Example of callback method</b><br>
This is what TimerProc1 might look like:
<pre>procedure TimerProc1(AOwner: TComponent); stdcall;
begin
  with (AOwner as TForm1) do
    ListBox1.Items.Add('SimpleTimer1 fired');
end;</pre>
</li>

<li><b>Changing the interval</b><br>
If you want to change the interval of a SimpleTimer object, simply call the Start method
with the new interval.
</li>
</ul>



<a name='Bugs'></a><h2>Known Bugs</h2>

<ul>
<li>You may experience occasionally that you lose a timer event when you work with
small intervals (approx. below 500 ms.). This is normal, and the same thing happens
with a TTimer object. If you want precision you need a multimedia timer, not
TTimer or TSimpleTimer which use the low-priority WM_TIMER message. WinXP has better 
handling of timers and will generally lose fewer timer events than other Windows versions.
</li>
</ul>



<a name='Comments'></a><h2>Comments</h2>

SimpleTimer is <i>freeware</i>. Feel free to use and improve it,
but <i>please include all original files if you redistribute the zip-file</i>.
If you have any comments or corrections I would very much like to hear them.
</p>

<p>
Get the latest version from <a href='http://www3.ewebcity.com/troels/delphi.asp'>
http://www3.ewebcity.com/troels/delphi.asp</a>.
</p>

<p>
Troels Jakobsen<br>
<a href='mailto:delphiuser@get2net.dk'>delphiuser@get2net.dk</a>
</p>

</body>
</html>

